Skip to content

Conversation

@jellejurre
Copy link
Contributor

No description provided.

Comment on lines 12 to 25
let mut header_map = HeaderMap::new();
header_map.append(
"Cookie",
HeaderValue::from_str(
&"auth=[AUTH_COOKIE_HERE]; twoFactorAuth=[TWO_FACTOR_AUTH_COOKIE_HERE]",
)
.unwrap(),
);

config.client = reqwest::Client::builder()
.cookie_store(true)
.default_headers(header_map)
.build()
.unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The better way to do this would be to create a cookie jar (similarly to cookie_store), and insert the required values before setting it as a cookie_provider.

Copy link
Collaborator

@C0D3-M4513R C0D3-M4513R Nov 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is what I'd do:

        let mut jar = reqwest::cookie::Jar::default();
        use std::str::FromStr;
        jar.set_cookies(&mut [HeaderValue::from_str(
            &"auth=[AUTH_COOKIE_HERE]; twoFactorAuth=[TWO_FACTOR_AUTH_COOKIE_HERE]",
        )], &url::Url::from_str("https://api.vrchat.cloud").expect("Url not okay"));
        let jar = Arc::new(jar);
        let client = reqwest::Client::builder()
            .cookie_provider(jar)
            .build()?;

This way the examples for loading and saving cookies could even be combined.

Comment on lines 12 to 25
let mut header_map = HeaderMap::new();
header_map.append(
"Cookie",
HeaderValue::from_str(
&"auth=[AUTH_COOKIE_HERE]; twoFactorAuth=[TWO_FACTOR_AUTH_COOKIE_HERE]",
)
.unwrap(),
);

config.client = reqwest::Client::builder()
.cookie_store(true)
.default_headers(header_map)
.build()
.unwrap();
Copy link
Collaborator

@C0D3-M4513R C0D3-M4513R Nov 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is what I'd do:

        let mut jar = reqwest::cookie::Jar::default();
        use std::str::FromStr;
        jar.set_cookies(&mut [HeaderValue::from_str(
            &"auth=[AUTH_COOKIE_HERE]; twoFactorAuth=[TWO_FACTOR_AUTH_COOKIE_HERE]",
        )], &url::Url::from_str("https://api.vrchat.cloud").expect("Url not okay"));
        let jar = Arc::new(jar);
        let client = reqwest::Client::builder()
            .cookie_provider(jar)
            .build()?;

This way the examples for loading and saving cookies could even be combined.

@C0D3-M4513R
Copy link
Collaborator

C0D3-M4513R commented Nov 25, 2024

Okay, github is stupid on that comment. It seems to have duplicated on the website, but when I edit one commit, it edit's both.

@jellejurre
Copy link
Contributor Author

Updated, but I dont think we should merge them, as it would be unclear what is part of the storing and what is part of the loading

@C0D3-M4513R
Copy link
Collaborator

Updated, but I dont think we should merge them, as it would be unclear what is part of the storing and what is part of the loading

Fair enough.

@jellejurre jellejurre merged commit 2b1bd59 into main Nov 25, 2024
3 checks passed
@jellejurre jellejurre deleted the feat/improve-examples branch November 25, 2024 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants